package com.action.schedule;
import com.db.schedule.*;

import java.util.*;
import java.text.*;

public class CalendarAction {
	private String sday;
	private String sday1;
	private int sabun;
		
	private ScheduleVO vo= new ScheduleVO();
	private ScheduleDAO scheduleDAO;
		
	public void setScheduleDAO(ScheduleDAO scheduleDAO) {
		this.scheduleDAO = scheduleDAO;
	}

	private List<ScheduleVO> list = new ArrayList<ScheduleVO>();
	
	public String getSday() {
		return sday;
	}

	public void setSday(String sday) {
		this.sday = sday;
	}

	public String getSday1() {
		return sday1;
	}

	public void setSday1(String sday1) {
		this.sday1 = sday1;
	}
	
	public int getSabun() {
		return sabun;
	}

	public void setSabun(int sabun) {
		this.sabun = sabun;
	}

	public void setVo(ScheduleVO vo) {
		this.vo = vo;
	}
	
		
	
/*-----------------------------------------------------------------*/
	
	public List<ScheduleVO> getList() {
		return list;
	}

	private String strWeek[] = {"일", "월", "화", "수", "목", "금", "토"};
	private int year;
	private int month;
	private int week;
	private int ed;
		
	public int getYear() {
		return year;
	}

	public int getMonth() {
		return month;
	}

	public int getWeek() {
		return week;
	}

	public int getEd() {
		return ed;
	}

	public String[] getStrWeek() {
		return strWeek;
	}
		
	public void setYear(int year) {
		this.year = year;
	}

	public void setMonth(int month) {
		this.month = month;
	}

	public String execute()throws Exception
	{
		Calendar cal= Calendar.getInstance();
		//현재 년도와 현재 달을 +1dms 0~11월 달까지 주어지기때문이
		int ny=cal.get(Calendar.YEAR);
		int nm=cal.get(Calendar.MONTH)+1;
		
		
		if(year==0&&month==0){
			year=ny;
			month=nm;
		}		
		if(month>12){
			year++;
			month=1;
		}
		if(month==0){
			year=year-1;
			/*System.out.println(year);*/
			month=12;
		}
		cal.set(year, month-1,1);
		
		ed=cal.getActualMaximum(Calendar.DAY_OF_MONTH);
		//cal.getActualMaximum는 그달의 마지막일 출력
		week=cal.get(Calendar.DAY_OF_WEEK);
		
			
				
			vo.setSabun(sabun);
			vo.setSday(String.valueOf(year));
			vo.setSday1(String.valueOf(month));
			/*System.out.println(sday+"|"+sday1);*/
			list=scheduleDAO.ScheduleAllData(vo);
			/*System.out.println(list.toString());*/
			
		
		return "success";		
		
	}
	
}
